package com.bing.app.executor.base.query;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.bing.app.model.base.vo.UserRecordVO;
import com.bing.common.model.PageResult;
import com.bing.domain.dao.base.entity.UserRecord;
import com.bing.domain.model.base.bo.AppUserPage;
import com.bing.domain.service.base.IUserRecordService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @Description 用户查询服务
 * @Author Bing
 * @Date 2025/8/22 9:28
 */
@Service
public class UserQueryService {

    @Resource
    private IUserRecordService userRecordService;

    public List<UserRecordVO> list(AppUserPage req){
        return BeanUtil.copyToList(userRecordService.pageList(req), UserRecordVO.class);
    }

    public PageResult<UserRecordVO> page(AppUserPage req){
        PageResult<UserRecord> pageResult =userRecordService.page(req);
        List<UserRecord> rows = pageResult.getRows();
        if(CollUtil.isEmpty(rows)){
            return PageResult.empty();
        }
        return PageResult.success(pageResult.getTotal(),BeanUtil.copyToList(rows, UserRecordVO.class));
    }
}